using System.Collections.Generic;
using Verse;

namespace RimWorld;

public class PawnsArrivalModeWorker_EdgeWalkInGroups : PawnsArrivalModeWorker
{
	public override void Arrive(List<Pawn> pawns, IncidentParms parms)
	{
		Map map = (Map)parms.target;
		List<Pair<List<Pawn>, IntVec3>> list = PawnsArrivalModeWorkerUtility.SplitIntoRandomGroupsNearMapEdge(pawns, map, arriveInPods: false);
		PawnsArrivalModeWorkerUtility.SetPawnGroupsInfo(parms, list);
		for (int i = 0; i < list.Count; i++)
		{
			for (int j = 0; j < list[i].First.Count; j++)
			{
				IntVec3 loc = CellFinder.RandomClosewalkCellNear(list[i].Second, map, 8);
				GenSpawn.Spawn(list[i].First[j], loc, map, parms.spawnRotation);
			}
		}
	}

	public override bool TryResolveRaidSpawnCenter(IncidentParms parms)
	{
		parms.spawnRotation = Rot4.Random;
		return true;
	}
}
